package com.devicemantra.coordinate.operations;
import java.io.IOException;

import javax.naming.spi.StateFactory;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.devicemantra.coordinate.exceptions.dataobjects.CDatabaseException;
import com.devicemantra.coordinate.exceptions.jaxb.CJAXBException;
import com.devicemantra.coordinate.exceptions.operations.CException;
import com.devicemantra.coordinate.exceptions.operations.COperationNotImplementedException;
import com.devicemantra.coordinate.exceptions.operations.CReadPayloadException;
import com.devicemantra.coordinate.exceptions.operations.CStateAlreadyExistsException;
import com.devicemantra.coordinate.exceptions.operations.CWritePayloadException;
import com.devicemantra.coordinate.interfaces.http.CHttpReader;
import com.devicemantra.coordinate.interfaces.http.CHttpWriter;
import com.devicemantra.coordinate.jaxb.JAXBRequestFactory;
import com.devicemantra.coordinate.jaxb.JAXBResponseFactory;
import com.devicemantra.coordinate.jaxb.ObjectFactory;
import com.devicemantra.coordinate.jaxb.OperationType;
import com.devicemantra.coordinate.jaxb.Request;
import com.devicemantra.coordinate.jaxb.Response;
import com.devicemantra.coordinate.jaxb.ResponseData;
import com.devicemantra.coordinate.jaxb.Status;
import com.devicemantra.coordinate.dataobjects.*;

@SuppressWarnings("serial")
public class AddLocation extends HttpServlet 
{
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException 
	{
		
		COperation lOperation = null;
		try {
			lOperation = COperationFactory.getServiceImpl(OperationType.ADD_LOCATION);
		} catch (COperationNotImplementedException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		
		}
		try {
			lOperation.processEvent(req,resp);
		} catch (CException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			lOperation.sendResponse();
		} catch (CException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
